function K = assembleMatrix(x)
    n = size(x, 2);
    K = zeros(n);
    for i = 1:n - 1
        x0 = x(i);
        x1 = x(i + 1);
        K(i, i) = K(i, i) + (x1 - x0) * quad(@phi0phi0, 0, 1);
        K(i, i + 1) = K(i, i + 1) + (x1 - x0) * quad(@phi0phi1, 0, 1);
        K(i + 1, i) = K(i + 1, i) + (x1 - x0) * quad(@phi0phi1, 0, 1);
        K(i + 1, i + 1) = K(i + 1, i + 1) + (x1 - x0) * quad(@phi1phi1, 0, 1);
    end
end